﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<web_uchet.Views.Shared.TemplateClasses.DateTimeTemplateViewData>" %>

<label for="<%= Model.ID %>"><%=Model.LabelText %></label>
<%= Html.TextBox( Model.Name, String.Format("{0:dd-MM-yyyy HH:mm}", Model.Value), new { @class = "input-box", id = Model.ID })%>
<%= Html.ValidationMessage(Model.Name, "*") %>

<script type="text/javascript">
    Now = new Date();
    jQuery("#<%= Model.ID %>").datetimepicker(
            {
                defaultDate: Now,
                constrainInput: false,
                showOn: 'button',
                onSelect: function (dateText, inst) 
                            { jQuery("#<%= Model.ID %>").datetimepicker("hide"); 
                              jQuery('#<%= Model.ID %>').closest("form").validate().element( "#<%= Model.ID %>" ); },
                showOnFocus: false,
                showTrigger: '<button type="button" class="trigger">' + 
                             '<img src="/Content/images/calendar.gif" alt="Popup"></button>'
            }
        );
        jQuery("#<%= Model.ID %>").mask("99-99-9999 99:99");
    <% if (Model.Value.HasValue) {%>
        jQuery("#<%= Model.ID %>").val('<%: String.Format("{0:dd-MM-yyyy HH:mm}", Model.Value) %>');
    <% } %>
</script>
